package graph;

/**
 * Superclass of nodes representing a binary operation. It has two member variables: 
 * the operation itself, and references to the left and right operand
 * @author Habib
 *
 */

public abstract class OperatorNode extends ValueNode
{
	/**
	 * The operation(+, -, *...)
	 */
	public String operator;
	
	/**
	 * A reference to the left operand
	 */
	public ValueNode leftOperand;
	
	/**
	 * A reference to the right operand
	 */
	public ValueNode rightOperand;
	
	/**
	 * Sets the operator
	 * @param op
	 */
	public void setOperator(String op)
	{
		operator = op;
	}
	
	/**
	 * Sets the left operand
	 * 
	 * @param node
	 */
	public void setLeftOperand(ValueNode node)
	{
		leftOperand = node;
	}
	
	/**
	 * Sets the right operand
	 * 
	 * @param node
	 */
	public void setRightOperand(ValueNode node)
	{
		rightOperand = node;
	}
	
	/**
	 * Returns the operator
	 * 
	 * @return
	 */
	public String getOperator()
	{
		return operator;
	}
	
	/**
	 * Returns the left operand
	 * 
	 * @return
	 */
	public ValueNode getLeftOperand()
	{
		return leftOperand;
	}
	
	/**
	 * Returns the right operand
	 * 
	 * @return
	 */
	public ValueNode getRightOperand()
	{
		return rightOperand;
	}

	@Override
	public String toString()
	{
		return operator;
	}
}